package com.lkd.controller;

import com.lkd.dto.VmTypePageDto;
import com.lkd.entity.VmType;
import com.lkd.result.PageBean;
import com.lkd.result.Result;
import com.lkd.service.VmTypeService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/vm-service/vmType")
public class VmTypeController {

    private final VmTypeService vmTypeService;
    //设备类型管理1.设备搜索
    @GetMapping("/search")
    public Result getPage(VmTypePageDto vmTypePageDto){
        PageBean pageBean = vmTypeService.list(vmTypePageDto);
        return Result.success(pageBean);
    }

    //设备类型管理2.设备新增
    @PostMapping
    public Result save(@RequestBody VmType vmType){
        Boolean result = vmTypeService.save(vmType);
        return Result.success(result);
    }

    //设备类型管理3.设备修改
    @PutMapping
    public Result update(@RequestBody VmType vmType){
        Boolean result = vmTypeService.update(vmType);
        return Result.success(result);
    }

    //设备类型管理4.设备删除
    @DeleteMapping("/{typeId}")
    public Result delete(@PathVariable Integer typeId){
        Boolean result = vmTypeService.delete(typeId);
        return Result.success(result);
    }
}
